﻿Imports System
Imports System.ComponentModel
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.WebControls
Imports Microsoft.Office.Server.Diagnostics

<ToolboxItemAttribute(False)> _
Public Class LibraryRibbonManager
    Inherits WebParts.WebPart

    '******* Pending tasks *******
    'private const string MENU_CONTROL_UPLOAD = "";
    'private const string MENU_ID_UPLOADDOCUMENT = "";
    'private const string MENU_ID_UPLOADMULTIPLE = "";  
    'private const string MENU_ID_EXPLORER = "";
    'private const string MENU_ID_OUTLOOK = "";     
    'private const string MENU_ID_DATABASE = "";

#Region "WebPart properties"

    '********************************************************************************************************************************************
    '*                                                             Ribbon Tab Settings
    '********************************************************************************************************************************************
    Private Const MENU_CONTROL_DOCUMENTS As String = "Ribbon.Document"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Documents' Tab"), Category("Ribbon Tab Settings")> _
    Public Property ShowDocumentsMenu() As Boolean
        Get
            Return ShowDocuments
        End Get
        Set(value As Boolean)
            ShowDocuments = value
        End Set
    End Property

    Private Const MENU_CONTROL_LIBRARY As String = "Ribbon.Library"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Library' Tab"), Category("Ribbon Tab Settings")> _
    Public Property ShowLibraryMenu() As Boolean
        Get
            Return ShowLibrary
        End Get
        Set(value As Boolean)
            ShowLibrary = value
        End Set
    End Property

    '********************************************************************************************************************************************
    '*                                                             Ribbon Group Settings
    '********************************************************************************************************************************************
    Private Const MENU_CONTROL_NEWGROUP As String = "Ribbon.Documents.New"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'New'"), Category("Ribbon Group Settings")> _
    Public Property ShowNewGroupMenu() As Boolean
        Get
            Return ShowNewGroup
        End Get
        Set(value As Boolean)
            ShowNewGroup = value
        End Set
    End Property

    Private Const MENU_CONTROL_EDITCHECKOUTGROUP As String = "Ribbon.Documents.EditCheckOut"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Open & Check Out'"), Category("Ribbon Group Settings")> _
    Public Property ShowEditCheckOutGroupMenu() As Boolean
        Get
            Return ShowEditCheckOutGroup
        End Get
        Set(value As Boolean)
            ShowEditCheckOutGroup = value
        End Set
    End Property

    Private Const MENU_CONTROL_VIEWFORMATGROUP As String = "Ribbon.Library.ViewFormat"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'View Format'"), Category("Ribbon Group Settings")> _
    Public Property ShowViewFormatGroupMenu() As Boolean
        Get
            Return ShowViewFormatGroup
        End Get
        Set(value As Boolean)
            ShowViewFormatGroup = value
        End Set
    End Property

    Private Const MENU_CONTROL_COPIES As String = "Ribbon.Documents.Copies"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Copies'"), Category("Ribbon Group Settings")> _
    Public Property ShowCopiesGroupMenu() As Boolean
        Get
            Return ShowCopiesGroup
        End Get
        Set(value As Boolean)
            ShowCopiesGroup = value
        End Set
    End Property

    Private Const MENU_CONTROL_CUSTOMVIEWS As String = "Ribbon.Library.CustomViews"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Manage Views'"), Category("Ribbon Group Settings")> _
    Public Property ShowCustomViewsGroupMenu() As Boolean
        Get
            Return ShowCustomViewsGroup
        End Get
        Set(value As Boolean)
            ShowCustomViewsGroup = value
        End Set
    End Property

    Private Const MENU_CONTROL_DOCUMENTSSHARETRACK As String = "Ribbon.Documents.Share"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Documents Share & Track'"), Category("Ribbon Group Settings")> _
    Public Property ShowDocumentsShareAndTrackGroupMenu() As Boolean
        Get
            Return ShowDocumentsShareAndTrackGroup
        End Get
        Set(value As Boolean)
            ShowDocumentsShareAndTrackGroup = value
        End Set
    End Property

    Private Const MENU_CONTROL_LIBRARYSHARETRACK As String = "Ribbon.Library.Share"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Library Share & Track'"), Category("Ribbon Group Settings")> _
    Public Property ShowLibraryShareAndTrackGroupMenu() As Boolean
        Get
            Return ShowLibraryShareAndTrackGroup
        End Get
        Set(value As Boolean)
            ShowLibraryShareAndTrackGroup = value
        End Set
    End Property

    Private Const MENU_CONTROL_ACTIONS As String = "Ribbon.Library.Actions"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Connect & Export'"), Category("Ribbon Group Settings")> _
    Public Property ShowActionsMenu() As Boolean
        Get
            Return ShowActions
        End Get
        Set(value As Boolean)
            ShowActions = value
        End Set
    End Property

    Private Const MENU_CONTROL_CUSTOMIZELIBRARY As String = "Ribbon.Library.CustomizeLibrary"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Customize Library'"), Category("Ribbon Group Settings")> _
    Public Property ShowCustomizeLibraryGroupMenu() As Boolean
        Get
            Return ShowCustomizeLibraryGroup
        End Get
        Set(value As Boolean)
            ShowCustomizeLibraryGroup = value
        End Set
    End Property

    Private Const MENU_CONTROL_SETTINGS As String = "Ribbon.Library.Settings"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Settings'"), Category("Ribbon Group Settings")> _
    Public Property ShowSettingsMenu() As Boolean
        Get
            Return Me.ShowItemSettings
        End Get
        Set(value As Boolean)
            Me.ShowItemSettings = value
        End Set
    End Property

    '********************************************************************************************************************************************
    '*                                                             Ribbon Documents Tab Settings
    '********************************************************************************************************************************************
    Private Const MENU_ID_NEW As String = "Ribbon.Documents.New.NewDocument"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'New'"), Category("Documents Tab Settings")> _
    Public Property ShowNewMenu() As Boolean
        Get
            Return ShowNew
        End Get
        Set(value As Boolean)
            ShowNew = value
        End Set
    End Property

    Private Const MENU_ID_NEWFOLDER As String = "Ribbon.Documents.New.NewFolder"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'New Folder'"), Category("Documents Tab Settings")> _
    Public Property ShowNewFolderMenu() As Boolean
        Get
            Return Showfolder
        End Get
        Set(value As Boolean)
            Showfolder = value
        End Set
    End Property

    Private Const MENU_ID_EDITITEM As String = "Ribbon.Documents.Manage.EditProperties"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Edit'"), Category("Documents Tab Settings")> _
    Public Property ShowEditMenu() As Boolean
        Get
            Return Me.ShowEdititem
        End Get
        Set(value As Boolean)
            Me.ShowEdititem = value
        End Set
    End Property

    Private Const MENU_ID_VERSIONS As String = "Ribbon.Documents.Manage.ViewVersions"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Versions'"), Category("Documents Tab Settings")> _
    Public Property ShowVersionsMenu() As Boolean
        Get
            Return Me.ShowVersions
        End Get
        Set(value As Boolean)
            Me.ShowVersions = value
        End Set
    End Property

    Private Const MENU_ID_ITEMPERMISSIONS As String = "Ribbon.Documents.Manage.ManagePermissions"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Permissions'"), Category("Documents Tab Settings")> _
    Public Property ShowPermissionsMenu() As Boolean
        Get
            Return Me.ShowItemPermissions
        End Get
        Set(value As Boolean)
            Me.ShowItemPermissions = value
        End Set
    End Property

    Private Const MENU_ID_DELETE As String = "Ribbon.Documents.Manage.Delete"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Delete'"), Category("Documents Tab Settings")> _
    Public Property ShowDeleteMenu() As Boolean
        Get
            Return Me.ShowDelete
        End Get
        Set(value As Boolean)
            Me.ShowDelete = value
        End Set
    End Property

    Private Const MENU_ID_DOWNLOADACOPY As String = "Ribbon.Documents.Copies.Download"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Download Copy'"), Category("Documents Tab Settings")> _
    Public Property ShowDownloadCopyMenu() As Boolean
        Get
            Return Me.ShowDownloadCopy
        End Get
        Set(value As Boolean)
            Me.ShowDownloadCopy = value
        End Set
    End Property

    Private Const MENU_ID_SENDTO As String = "Ribbon.Documents.Copies.SendTo"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Send To'"), Category("Documents Tab Settings")> _
    Public Property ShowSendToMenu() As Boolean
        Get
            Return Me.ShowSendTo
        End Get
        Set(value As Boolean)
            Me.ShowSendTo = value
        End Set
    End Property

    Private Const MENU_ID_MANAGECOPIES As String = "Ribbon.Documents.Copies.ManageCopies"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Manage Copies'"), Category("Documents Tab Settings")> _
    Public Property ShowManageCopiesMenu() As Boolean
        Get
            Return Me.ShowManageCopies
        End Get
        Set(value As Boolean)
            Me.ShowManageCopies = value
        End Set
    End Property

    Private Const MENU_ID_EDITCHECKOUT As String = "Ribbon.Documents.EditCheckOut.CheckOut"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Edit Check Out'"), Category("Documents Tab Settings")> _
    Public Property ShowEditCheckOutMenu() As Boolean
        Get
            Return Me.ShowEditCheckOut
        End Get
        Set(value As Boolean)
            Me.ShowEditCheckOut = value
        End Set
    End Property

    Private Const MENU_ID_UPLOADDOCUMENT As String = "Ribbon.Documents.New.AddDocument"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Upload Document'"), Category("Documents Tab Settings")> _
    Public Property ShowUploadDocumentMenu() As Boolean
        Get
            Return Me.ShowUploadDocument
        End Get
        Set(value As Boolean)
            Me.ShowUploadDocument = value
        End Set
    End Property

    Private Const MENU_ID_UPLOADMULTIPLE As String = "Ribbon.Documents.New.AddDocument.Menu.Upload.UploadMultiple"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Upload Multiple'"), Category("Documents Tab Settings")> _
    Public Property ShowUploadMultipleMenu() As Boolean
        Get
            Return Me.ShowUploadMultiple
        End Get
        Set(value As Boolean)
            Me.ShowUploadMultiple = value
        End Set
    End Property

    Private Const MENU_ID_VIEWPROPERTIES As String = "Ribbon.Documents.Manage.ViewProperties"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'View Properties'"), Category("Documents Tab Settings")> _
    Public Property ShowViewPropertiesMenu() As Boolean
        Get
            Return Me.ShowViewproperties
        End Get
        Set(value As Boolean)
            Me.ShowViewproperties = value
        End Set
    End Property

    Private Const MENU_ID_EMAILDOCUMENTLINK As String = "Ribbon.Docuemnts.Share.EmailLibraryLink"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Send e-Mail Document Link'"), Category("Documents Tab Settings")> _
    Public Property ShowEmailDocumentLinkMenu() As Boolean
        Get
            Return Me.ShowEmailDocumentlink
        End Get
        Set(value As Boolean)
            Me.ShowEmailDocumentlink = value
        End Set
    End Property

    Private Const MENU_ID_DOCUMENTSALERTME As String = "Ribbon.Documents.Share.AlertMe"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Alert Me'"), Category("Documents Tab Settings")> _
    Public Property ShowDocumentsAlertMenu() As Boolean
        Get
            Return Me.ShowDocumentsAlertme
        End Get
        Set(value As Boolean)
            Me.ShowDocumentsAlertme = value
        End Set
    End Property

    '********************************************************************************************************************************************
    '*                                                             Ribbon Library Tab Settings
    '********************************************************************************************************************************************

    Private Const MENU_ID_LIBRARYALERTME As String = "Ribbon.Library.Share.AlertMe"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Alert Me'"), Category("Library Tab Settings")> _
    Public Property ShowLibraryAlertMeMenu() As Boolean
        Get
            Return Me.ShowLibraryAlertme
        End Get
        Set(value As Boolean)
            Me.ShowLibraryAlertme = value
        End Set
    End Property

    Private Const MENU_ID_EMAILLIBRARYLINK As String = "Ribbon.Library.Share.EmailLibraryLink"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Send e-Mail Library Link'"), Category("Library Tab Settings")> _
    Public Property ShowEmailLibraryLinkMenu() As Boolean
        Get
            Return Me.ShowEmailLibrarylink
        End Get
        Set(value As Boolean)
            Me.ShowEmailLibrarylink = value
        End Set
    End Property

    Private Const MENU_ID_OPENWITHEXPLORER As String = "Ribbon.Library.Actions.OpenWithExplorer"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Open with Explorer'"), Category("Library Tab Settings")> _
    Public Property ShowOpenWithExplorerMenu() As Boolean
        Get
            Return Me.ShowOpenWithExplorer
        End Get
        Set(value As Boolean)
            Me.ShowOpenWithExplorer = value
        End Set
    End Property

    Private Const MENU_ID_EDITDEFAULTFORMS As String = "Ribbon.Library.CustomizeLibrary.EditDefaultForms"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Edit Default Forms'"), Category("Library Tab Settings")> _
    Public Property ShowEditDefaultFormsMenu() As Boolean
        Get
            Return Me.ShowEditDefaultForms
        End Get
        Set(value As Boolean)
            Me.ShowEditDefaultForms = value
        End Set
    End Property

    Private Const MENU_ID_CONNECTTOCLIENT As String = "Ribbon.Library.Actions.ConnectToClient"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Connect To Office'"), Category("Library Tab Settings")> _
    Public Property ShowConnectToClientMenu() As Boolean
        Get
            Return Me.ShowConnectToClient
        End Get
        Set(value As Boolean)
            Me.ShowConnectToClient = value
        End Set
    End Property

    Private Const MENU_ID_WORKFLOW As String = "Ribbon.Documents.Workflow.ViewWorkflows"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Workflow'"), Category("Library Tab Settings")> _
    Public Property ShowWorkflowMenu() As Boolean
        Get
            Return Me.ShowWorkflow
        End Get
        Set(value As Boolean)
            Me.ShowWorkflow = value
        End Set
    End Property

    Private Const MENU_ID_QUICKSTEPS As String = "Ribbon.Documents.QuickSteps"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'QuickSteps'"), Category("Library Tab Settings")> _
    Public Property ShowQuickStepsMenu() As Boolean
        Get
            Return Me.ShowQuickSteps
        End Get
        Set(value As Boolean)
            Me.ShowQuickSteps = value
        End Set
    End Property

    Private Const MENU_ID_DEFAULTVIEW As String = "Ribbon.Library.ViewFormat.Standard"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Default View'"), Category("Library Tab Settings")> _
    Public Property ShowDefaultViewMenu() As Boolean
        Get
            Return Me.ShowDefaultview
        End Get
        Set(value As Boolean)
            Me.ShowDefaultview = value
        End Set
    End Property

    Private Const MENU_ID_DATASHEET As String = "Ribbon.Library.ViewFormat.Datasheet"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'DataSheet'"), Category("Library Tab Settings")> _
    Public Property ShowDataSheetMenu() As Boolean
        Get
            Return Me.ShowDatasheet
        End Get
        Set(value As Boolean)
            Me.ShowDatasheet = value
        End Set
    End Property

    Private Const MENU_ID_NEWROW As String = "Ribbon.Library.Datasheet.NewRow"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'New Row'"), Category("Library Tab Settings")> _
    Public Property ShowNewRowMenu() As Boolean
        Get
            Return Me.ShowNewrow
        End Get
        Set(value As Boolean)
            Me.ShowNewrow = value
        End Set
    End Property

    Private Const MENU_ID_CREATEVIEW As String = "Ribbon.Library.CustomViews.CreateView"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Create View'"), Category("Library Tab Settings")> _
    Public Property ShowCreateViewMenu() As Boolean
        Get
            Return Me.ShowCreateview
        End Get
        Set(value As Boolean)
            Me.ShowCreateview = value
        End Set
    End Property

    Private Const MENU_ID_MODIFYVIEW As String = "Ribbon.Library.CustomViews.ModifyView"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Modify View'"), Category("Library Tab Settings")> _
    Public Property ShowModifyViewMenu() As Boolean
        Get
            Return Me.ShowModifyview
        End Get
        Set(value As Boolean)
            Me.ShowModifyview = value
        End Set
    End Property

    Private Const MENU_ID_SELECTVIEW As String = "Ribbon.Library.CustomViews.DisplayView"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Select View'"), Category("Library Tab Settings")> _
    Public Property ShowSelectViewMenu() As Boolean
        Get
            Return Me.ShowSelectView
        End Get
        Set(value As Boolean)
            Me.ShowSelectView = value
        End Set
    End Property

    Private Const MENU_ID_ADDCOLUMN As String = "Ribbon.Library.CustomViews.CreateColumn"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Add Column'"), Category("Library Tab Settings")> _
    Public Property ShowAddColumnMenu() As Boolean
        Get
            Return Me.ShowAddcolumn
        End Get
        Set(value As Boolean)
            Me.ShowAddcolumn = value
        End Set
    End Property

    Private Const MENU_ID_NAVIGATEUP As String = "Ribbon.Library.CustomViews.NavigateUp"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Navigate Up'"), Category("Library Tab Settings")> _
    Public Property ShowNavigateUpMenu() As Boolean
        Get
            Return Me.ShowNavigateup
        End Get
        Set(value As Boolean)
            Me.ShowNavigateup = value
        End Set
    End Property

    Private Const MENU_ID_CURRENTVIEW As String = "Ribbon.Library.CustomViews.CurrentView"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Current View'"), Category("Library Tab Settings")> _
    Public Property ShowCurrenteViewMenu() As Boolean
        Get
            Return Me.ShowCurrentview
        End Get
        Set(value As Boolean)
            Me.ShowCurrentview = value
        End Set
    End Property

    Private Const MENU_ID_RSS As String = "Ribbon.Library.Share.ViewRSSFeed"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Source RSS'"), Category("Library Tab Settings")> _
    Public Property ShowRssMenu() As Boolean
        Get
            Return Me.ShowRss
        End Get
        Set(value As Boolean)
            Me.ShowRss = value
        End Set
    End Property

    Private Const MENU_ID_EXPORTSPREADSHEET As String = "Ribbon.Library.Actions.ExportToSpreadsheet"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Export To Spreadsheet'"), Category("Library Tab Settings")> _
    Public Property ShowExportExcelMenu() As Boolean
        Get
            Return Me.ShowExportToSpreadsheet
        End Get
        Set(value As Boolean)
            Me.ShowExportToSpreadsheet = value
        End Set
    End Property

    Private Const MENU_ID_OUTLOOK As String = "Ribbon.Library.Actions.ConnectToClient"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Connect to Outlook'"), Category("Library Tab Settings")> _
    Public Property ShowOutlookMenu() As Boolean
        Get
            Return Me.ShowOutlook
        End Get
        Set(value As Boolean)
            Me.ShowOutlook = value
        End Set
    End Property

    Private Const MENU_ID_WORKSPACE As String = "Ribbon.Library.Actions.TakeOfflineToClient"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Export to WorkSpace'"), Category("Library Tab Settings")> _
    Public Property ShowWorkSpaceMenu() As Boolean
        Get
            Return Me.ShowWorkspace
        End Get
        Set(value As Boolean)
            Me.ShowWorkspace = value
        End Set
    End Property


    Private Const MENU_ID_PERMISSIONS As String = "Ribbon.Library.Settings.LibraryPermissions"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Permissions'"), Category("Library Tab Settings")> _
    Public Property ShowLibraryPermissionsMenu() As Boolean
        Get
            Return Me.ShowLibraryPermissions
        End Get
        Set(value As Boolean)
            Me.ShowLibraryPermissions = value
        End Set
    End Property

    Private Const MENU_ID_WORKFLOWS As String = "Ribbon.Library.Settings.ManageWorkflows"

    <Personalizable(PersonalizationScope.[Shared]), WebBrowsable(True), WebDisplayName("Show 'Workflows' Menu"), Category("Library Tab Settings")> _
    Public Property ShowWorkFlowsMenu() As Boolean
        Get
            Return Me.ShowWorkflows
        End Get
        Set(value As Boolean)
            Me.ShowWorkflows = value
        End Set
    End Property
#End Region

#Region "Private properties"

    Private ShowLibrary As Boolean = True
    Private ShowDocuments As Boolean = True
    Private ShowNewGroup As Boolean = True
    Private ShowEditCheckOutGroup As Boolean = True
    Private ShowCopiesGroup As Boolean = True
    Private ShowViewFormatGroup As Boolean = True
    Private ShowCustomViewsGroup As Boolean = True
    Private ShowLibraryShareAndTrackGroup As Boolean = True
    Private ShowDocumentsShareAndTrackGroup As Boolean = True
    Private ShowCustomizeLibraryGroup As Boolean = True
    Private ShowActions As Boolean = True
    Private ShowItemSettings As Boolean = True
    Private ShowNew As Boolean = True
    Private Showfolder As Boolean = True
    Private ShowEdititem As Boolean = True
    Private ShowVersions As Boolean = True
    Private ShowItemPermissions As Boolean = True
    Private ShowDelete As Boolean = True
    Private ShowDownloadCopy As Boolean = True
    Private ShowSendTo As Boolean = True
    Private ShowManageCopies As Boolean = True
    Private ShowOpenWithExplorer As Boolean = True
    Private ShowEditDefaultForms As Boolean = True
    Private ShowConnectToClient As Boolean = True
    Private ShowEditCheckOut As Boolean = True
    Private ShowUploadMultiple As Boolean = True
    Private ShowUploadDocument As Boolean = True
    Private ShowDocumentsAlertme As Boolean = True

    Private ShowLibraryAlertme As Boolean = True
    Private ShowWorkflow As Boolean = True
    Private ShowQuickSteps As Boolean = True
    Private ShowDefaultview As Boolean = True
    Private ShowDatasheet As Boolean = True
    Private ShowNewrow As Boolean = True
    Private ShowCreateview As Boolean = True
    Private ShowViewproperties As Boolean = True
    Private ShowModifyview As Boolean = True
    Private ShowAddcolumn As Boolean = True
    Private ShowNavigateup As Boolean = True
    Private ShowCurrentview As Boolean = True
    Private ShowEmailLibrarylink As Boolean = True
    Private ShowEmailDocumentlink As Boolean = True
    Private ShowRss As Boolean = True
    Private ShowExportToSpreadsheet As Boolean = True
    Private ShowOutlook As Boolean = True
    Private ShowWorkspace As Boolean = True
    Private ShowLibraryPermissions As Boolean = True
    Private ShowWorkflows As Boolean = True
    Private ShowSelectView As Boolean = True

#End Region

    '***********************************************************************************************************
    '* Pre render webpart HTML event handler
    '***********************************************************************************************************
    Protected Overrides Sub OnPreRender(e As EventArgs)
        ExamineControls()
    End Sub

    '***********************************************************************************************************
    '* Method that renders and disables buttons and features of a ribbon into the page where the webpart is put
    '***********************************************************************************************************
    Private Sub ExamineControls()
        Dim ribbon As SPRibbon = SPRibbon.GetCurrent(Me.Page)

        If ribbon IsNot Nothing Then

            If Not Me.ShowLibrary Then
                Try
                    ribbon.TrimById(MENU_CONTROL_LIBRARY)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowDocuments Then
                Try
                    ribbon.TrimById(MENU_CONTROL_DOCUMENTS)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowNewGroup Then
                Try
                    ribbon.TrimById(MENU_CONTROL_NEWGROUP)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowEditCheckOutGroup Then
                Try
                    ribbon.TrimById(MENU_CONTROL_EDITCHECKOUTGROUP)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowCopiesGroup Then
                Try
                    ribbon.TrimById(MENU_CONTROL_COPIES)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowViewFormatGroup Then
                Try
                    ribbon.TrimById(MENU_CONTROL_VIEWFORMATGROUP)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If
            If Not Me.ShowCustomViewsGroup Then
                Try
                    ribbon.TrimById(MENU_CONTROL_CUSTOMVIEWS)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowLibraryShareAndTrackGroup Then
                Try
                    ribbon.TrimById(MENU_CONTROL_LIBRARYSHARETRACK)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowDocumentsShareAndTrackGroup Then
                Try
                    ribbon.TrimById(MENU_CONTROL_DOCUMENTSSHARETRACK)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowActions Then
                Try
                    ribbon.TrimById(MENU_CONTROL_ACTIONS)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowCustomizeLibraryGroup Then
                Try
                    ribbon.TrimById(MENU_CONTROL_CUSTOMIZELIBRARY)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowItemSettings Then
                Try
                    ribbon.TrimById(MENU_CONTROL_SETTINGS)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowNew Then
                Try
                    ribbon.TrimById(MENU_ID_NEW)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.Showfolder Then
                Try
                    ribbon.TrimById(MENU_ID_NEWFOLDER)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowEdititem Then
                Try
                    ribbon.TrimById(MENU_ID_EDITITEM)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowVersions Then
                Try
                    ribbon.TrimById(MENU_ID_VERSIONS)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowItemPermissions Then
                Try
                    ribbon.TrimById(MENU_ID_ITEMPERMISSIONS)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowDelete Then
                Try
                    ribbon.TrimById(MENU_ID_DELETE)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowDownloadCopy Then
                Try
                    ribbon.TrimById(MENU_ID_DOWNLOADACOPY)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowSendTo Then
                Try
                    ribbon.TrimById(MENU_ID_SENDTO)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowManageCopies Then
                Try
                    ribbon.TrimById(MENU_ID_MANAGECOPIES)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowOpenWithExplorer Then
                Try
                    ribbon.TrimById(MENU_ID_OPENWITHEXPLORER)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowEditDefaultForms Then
                Try
                    ribbon.TrimById(MENU_ID_EDITDEFAULTFORMS)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowConnectToClient Then
                Try
                    ribbon.TrimById(MENU_ID_CONNECTTOCLIENT)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowEditCheckOut Then
                Try
                    ribbon.TrimById(MENU_ID_EDITCHECKOUT)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowUploadMultiple Then
                Try
                    ribbon.TrimById(MENU_ID_UPLOADMULTIPLE)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowUploadDocument Then
                Try
                    ribbon.TrimById(MENU_ID_UPLOADDOCUMENT)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowDocumentsAlertme Then
                Try
                    ribbon.TrimById(MENU_ID_DOCUMENTSALERTME)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowLibraryAlertme Then
                Try
                    ribbon.TrimById(MENU_ID_LIBRARYALERTME)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowWorkflow Then
                Try
                    ribbon.TrimById(MENU_ID_WORKFLOW)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowWorkflow Then
                Try
                    ribbon.TrimById(MENU_ID_WORKFLOW)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowDatasheet Then
                Try
                    ribbon.TrimById(MENU_ID_DATASHEET)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowNewrow Then
                Try
                    ribbon.TrimById(MENU_ID_NEWROW)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowCreateview Then
                Try
                    ribbon.TrimById(MENU_ID_CREATEVIEW)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowViewproperties Then
                Try
                    ribbon.TrimById(MENU_ID_VIEWPROPERTIES)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowModifyview Then
                Try
                    ribbon.TrimById(MENU_ID_MODIFYVIEW)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowAddcolumn Then
                Try
                    ribbon.TrimById(MENU_ID_ADDCOLUMN)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowNavigateup Then
                Try
                    ribbon.TrimById(MENU_ID_NAVIGATEUP)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowCurrenteViewMenu Then
                Try
                    ribbon.TrimById(MENU_ID_CURRENTVIEW)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowEmailDocumentlink Then
                Try
                    ribbon.TrimById(MENU_ID_EMAILDOCUMENTLINK)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowEmailLibrarylink Then
                Try
                    ribbon.TrimById(MENU_ID_EMAILLIBRARYLINK)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowRss Then
                Try
                    ribbon.TrimById(MENU_ID_RSS)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowExportToSpreadsheet Then
                Try
                    ribbon.TrimById(MENU_ID_EXPORTSPREADSHEET)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowOutlook Then
                Try
                    ribbon.TrimById(MENU_ID_OUTLOOK)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowWorkspace Then
                Try
                    ribbon.TrimById(MENU_ID_WORKSPACE)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowLibraryPermissions Then
                Try
                    ribbon.TrimById(MENU_ID_PERMISSIONS)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowWorkflows Then
                Try
                    ribbon.TrimById(MENU_ID_WORKFLOWS)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If

            If Not Me.ShowSelectView Then
                Try
                    ribbon.TrimById(MENU_ID_SELECTVIEW)
                Catch ex As Exception
                    'Write to the SharePoint ULS Log
                    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on ASCII.WebPart.LibraryRibbonManager: {0} || {1}", ex.Message, ex.StackTrace)
                End Try
            End If
        End If

    End Sub
End Class
